package com.bookstore.servlet;

import com.bookstore.pojo.Book;
import com.bookstore.services.BookService;
import com.bookstore.services.Impl.BookServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet(name = "BookServlet", value = "/BookServlet")
public class BookServlet extends BaseServlet {
    BookService bookService=new BookServiceImpl();

    /**
     * 根据分页查询
     * @param request
     * @param response
     * @throws ServletException
     * @throws IOException
     */
    protected void queryAll(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("此处出现问题");
        String min = request.getParameter("min");
        String max = request.getParameter("max");
        String pageNo = request.getParameter("pageNo");
        String size = request.getParameter("size");
        List<Book> books = bookService.getPageByPrice(min, max, pageNo, size);
        request.setAttribute("books",books);
        request.getRequestDispatcher("pages/client/index.jsp").forward(request,response);
    }

}
